package ch08;

public class ColorMain {
    private static void changeColor(Color color){
        color = Color.GREEN;
        System.out.println("change: "+color);
    }
    public static void main(String[] args) {
        for (Color color:Color.values()) {
            System.out.println(color.ordinal() + " : "+color);
        }
        System.out.println(Color.RED.compareTo(Color.BLUE));
        System.out.println(Color.RED.compareTo(Color.BLACK));
        System.out.println(Color.BLACK.compareTo(Color.RED));
        System.out.println(Color.BLACK.equals(Color.RED));
        System.out.println(Color.BLACK==Color.RED);

        Color c = Color.RED;
        changeColor(c);// 按值传参  传的是复印件
        System.out.println(c);// 里面改了 外边不改
        c = Color.values()[2];// 2 就是对应的int 也是我们的枚举下标
        System.out.println(c);
    }
}

enum Color{
    RED,BLUE,BLACK,YELLOW,GREEN;// 默认底层是int 0 开始
}
